package com.zlz.generate.config;

import com.zlz.generate.util.DataSourceCache;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author wb_zhulinzhong
 * @date 2021-04-19 18:01:24
 */
@Component
public class DynamicDataSource extends AbstractRoutingDataSource {
    @Resource
    private DataSourceCache dataSourceCache;

    @Override
    protected Object determineCurrentLookupKey() {
        return dataSourceCache.getUsed();
    }

}
